<?php
/* 用户表 */
namespace app\console\model;
use think\Db;
use think\Model;
use think\Log;

class Customer extends Model {


    protected $tableName = 'customer';
    
    /*
     * 获取用户最后订单的状态以及设备类型
     */
    public function getCustomerLastConsumeData($customerID){
        if(!(int)$customerID){
            return false;
        }
        $data=Db::connect("tianshendai_read")->name('consume_history')->where(['customer_id'=>$customerID])->field('system_type,status')->order(['id'=>'DESC'])->find();
        return $data;
    }
    
    
    /*
     * 获取用户最后订单的状态以及设备类型
     */
    public function getPushIdByCustomerID($customerID){
        if(!(int)$customerID){
            return false;
        }
        $tableName=getCustomerTableByCustomerID($customerID);
        if(!$tableName){
            return false;
        }
        $data=Db::connect("tianshendai_read")->name($tableName)->where(['id'=>$customerID,'push_id'=>['neq','']])->field('push_id')->find();
        Log::write('Customer<>getPushIdByCustomerID<>'.$customerID.':'.Db::connect("tianshendai_read")->name($tableName)->getLastSql());
        return $data;
    }
}